<template>
    <view class="content">
        <view style="height: 20rpx;"></view>
        <view class="item" v-for="(item,index) in list" :key="index" @click="goNews(item.id)">
            <image :src="item.title_pic_url" class="pic"></image>
            <view class="texx">
                <view class="t1 u-line-1">{{item.title}}</view>
                <view class="spx u-line-2">{{item.ftitle}}</view>
                <view class="times">{{item.create_time}}</view>
            </view>
        </view>
        
        <view style="height: 94rpx;padding-top: 30rpx;">
            <u-loadmore :status="status" v-if="status != 'loadmore'" />
        </view>
    </view>
</template>
    
<script>
    export default {
        data() {
            return {
                status: 'loadmore', //是否显示没有更多了
                page: 1,
                list: [],
            };
        },
        onLoad(option) {
            this.getList()
        },
        onReachBottom() {
        	if(this.page == 1){return}
        	this.getList()
        },
        methods: {
            goNews(id) {
                this.$gTo(`/pages/news/detail?id=${id}`)
            },
            
            getList() {
            	if (this.status == 'nomore') return;
            	this.status = 'loading';
            	this.$ajax('contentsList', {
                    userToken: this.$getSync('userToken'),
                    page: this.page,
                    limit: 10,
                    column_id: 7,//1-平台公告 7-新闻资讯
                }).then(ret => {
            		if (ret.status == 0) {
                        if (ret.data.length > 0) {
                        	this.list = this.list.concat(ret.data);
                        	this.page++;
                        	this.status = 'loadmore'
                        } else {
                        	this.status = 'nomore'
                        }
            		} else {
            			this.$toast(ret.message);
            		}
            	});
            },
        }
    };
</script>

<style scoped lang="scss">
    .item {
        width: 700rpx;
        display: flex;
        justify-content: space-between;
        margin: 0 auto 50rpx;

        .pic {
            width: 220rpx;
            height: 150rpx;
            border-radius: 14rpx;
            margin-right: 20rpx;
        }

        .texx {
            flex: 1;
            width: 0;
            padding-top: 6rpx;

            .t1 {
                font-size: 30rpx;
                color: #000;
                line-height: 42rpx;
                font-weight: 700;
            }

            .spx {
                font-size: 24rpx;
                color: #848484;
                line-height: 36rpx;
                height: 72rpx;
            }

            .times {
                font-size: 24rpx;
                color: #848484;
            }
        }
    }
</style>